package com.sbio.udiapp.common.bean;

import androidx.annotation.NonNull;

import com.alibaba.fastjson.JSON;
import com.sbio.udiapp.util.CommonUtil;
import com.sbio.udiapp.util.DefaultSharedPreferencesUtil;

import java.lang.reflect.Method;

/**
 * 请求统一参数
 */
public class RequestUniParam {

    String module;

    String method;

    String content;

    /**
     * 设备编码
     */
    String deviceNo;

    public String getModule() {
        return module;
    }

    public void setModule(String module) {
        this.module = module;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getDeviceNo() {
        return deviceNo;
    }

    public void setDeviceNo(String deviceNo) {
        this.deviceNo = deviceNo;
    }



    @NonNull
    public static RequestUniParam create(String content) {
        String deviceNo = DefaultSharedPreferencesUtil.getDeviceNo();
        Method currentMethod = CommonUtil.getCurrentMethod();
        RequestUniParam requestUniParam = new RequestUniParam();
        requestUniParam.setModule(currentMethod.getDeclaringClass().getName());
        requestUniParam.setMethod(currentMethod.getName());
        requestUniParam.setContent(content);
        requestUniParam.setDeviceNo(deviceNo);
        return requestUniParam;
    }

    public String toJson() {
        return JSON.toJSONString(this);
    }

}
